package com.kantboot.business.talent.domain.entity;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.kantboot.util.core.jpa.KantbootGenerationType;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.io.Serializable;
import java.util.Date;

/**
 * 对应用户账号的人才奖项
 */
@Entity
@Getter
@Setter
@Table(name = "bus_talent_award_of_user_account")
@Accessors(chain = true)
@EntityListeners(AuditingEntityListener.class)
@DynamicUpdate
@DynamicInsert
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
public class BusTalentAwardOfUserAccount implements Serializable {

    /**
     * 主键
     */
    @Id
    @GenericGenerator(name = "snowflakeId", strategy = KantbootGenerationType.SNOWFLAKE)
    @GeneratedValue(generator = "snowflakeId")
    @Column(name = "id")
    private Long id;

    /**
     * 创建时间
     */
    @CreatedDate
    @Column(name = "gmt_create")
    private Date gmtCreate;

    /**
     * 修改时间
     */
    @LastModifiedDate
    @Column(name = "gmt_modified")
    private Date gmtModified;

    /**
     * 用户账号ID
     */
    @Column(name = "user_account_id")
    private Long userAccountId;

    /**
     * 人才奖项ID
     */
    @Column(name = "talent_award_id")
    private Long talentAwardId;

    @OneToOne
    @JoinColumn(name = "talent_award_id", insertable = false, updatable = false)
    private BusTalentAward talentAward;

    /**
     * 是否为主要贡献者
     */
    @Column(name = "is_main_contributor")
    private Boolean isMainContributor;

    /**
     * 名次
     */
    @Column(name = "t_rank")
    private Integer rank;

    /**
     * 等次
     */
    @Column(name = "t_grade")
    private Integer grade;

    /**
     * 获得时间
     */
    @Column(name = "gmt_get")
    private Date gmtGet;

}